import request from '@/utils/request'

export function queryByIds(query) {
  return request({
    url: '/platform/running/queryByIds?'+query,
    method: 'get'
  })
}


// 查询机器人实例列表
export function listRunning(query) {
  return request({
    url: '/platform/running/list',
    method: 'get',
    params: query
  })
}

export function listResources(userId) {
  return request({
    url: '/platform/running/resources/' + userId,
    method: 'get'
  })
}

export function listResources2() {
  return request({
    url: '/platform/running/resources',
    method: 'get'
  })
}

// 查询机器人实例详细
export function getRunning(runningId) {
  return request({
    url: '/platform/running/' + runningId,
    method: 'get'
  })
}

// 新增机器人实例
export function addRunning(data) {
  return request({
    url: '/platform/running',
    method: 'post',
    data: data
  })
}

// 修改机器人实例
export function updateRunning(data) {
  return request({
    url: '/platform/running',
    method: 'put',
    data: data
  })
}

// 删除机器人实例
export function delRunning(runningId) {
  return request({
    url: '/platform/running/' + runningId,
    method: 'delete'
  })
}

// 导出机器人实例
export function exportRunning(query) {
  return request({
    url: '/platform/running/export',
    method: 'get',
    params: query
  })
}

//创建容器
export function createContainer(runningId) {
  return request({
    url: '/platform/running/containers/create?endpointId=2&runningId=' + runningId,
    method: 'put'
  })
}

//创建容器
export function inspectContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/inspect',
    method: 'get'
  })
}


//启动容器
export function startContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/start',
    method: 'put'
  })
}

//停止容器
export function stopContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/stop',
    method: 'put'
  })
}

//重启容器
export function restartContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/restart',
    method: 'put'
  })
}

//暂停容器
export function pauseContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/pause',
    method: 'put'
  })
}


//更新版本
export function updateVersion(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/update_version',
    method: 'put'
  })
}

//恢复容器
export function revertContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/reverse',
    method: 'put'
  })
}

//删除容器
export function deleteContainer(runningId) {
  return request({
    url: '/platform/running/running/' + runningId + '/remove',
    method: 'put'
  })
}


//删除容器
export function getCurrentBalance(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/current',
    method: 'get',
    params: query
  })
}

export function getAccountReport(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/report',
    method: 'get',
    params: query
  })
}

export function getAvgPrice(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/avg',
    method: 'get',
    params: query
  })
}

export function analyseDepths(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/analyseDepths',
    method: 'get',
    params: query
  })
}

export function getTicker(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/ticker',
    method: 'get',
    params: query
  })
}

export function usdtCurrent(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/usdtCurrent',
    method: 'get',
    params: query
  })
}

export function placeOrder(runningId, data) {
  return request({
    url: '/platform/running/containers/' + runningId + '/placeOrder',
    method: 'post',
    data: data
  })
}

export function safeStop(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/safe_stop',
    method: 'get',
    params: query
  })
}


export function configAction(runningId, data) {
  return request({
    url: '/platform/running/containers/' + runningId + '/config_action',
    method: 'post',
    data: data
  })
}


export function cancelOrder(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/cancelOrder',
    method: 'delete',
    params: query
  })
}


export function getFlyOrder(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/queryFlyOrders',
    method: 'get',
    params: query
  })
}

export function getDealedOrder(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/getDealedOrder',
    method: 'get',
    params: query
  })
}

export function deleteTrigger(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/delete',
    method: 'delete',
    params: query
  })
}

export function activeAll(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/activeAll',
    method: 'get',
    params: query
  })
}


export function closeAll(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/closeAll',
    method: 'get',
    params: query
  })
}


export function freshAll(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/freshAll',
    method: 'get',
    params: query
  })
}

export function freshTrigger(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/fresh',
    method: 'get',
    params: query
  })
}

export function activeTrigger(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/active',
    method: 'get',
    params: query
  })
}

export function closeTrigger(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/close',
    method: 'get',
    params: query
  })
}

export function listTrigger(runningId, query) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/list',
    method: 'get',
    params: query
  })
}


export function createTrigger(runningId, data) {
  return request({
    url: '/platform/running/containers/' + runningId + '/trigger/create',
    method: 'post',
    data: data
  })
}









